<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>ln</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_001_014_1156">&nbsp;</a>NAME</h4><blockquote>
ln - link files
</blockquote><h4><a name = "tag_001_014_1157">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

ln <b>[</b>-f<b>] </b><i>source_file target_file</i>

ln <b>[</b>-f<b>] </b><i>source_file</i>... <i>target_dir</i>
</code>
</pre>
</blockquote><h4><a name = "tag_001_014_1158">&nbsp;</a>DESCRIPTION</h4><blockquote>
In the first synopsis form, the
<i>ln</i>
utility will create a new directory entry (link) for the
file specified by the
<i>source_file</i>
operand, at the
<i>destination</i>
path specified by the
<i>target_file</i>
operand.
This first synopsis form is assumed when the final operand does not name
an existing directory;
if more than two operands are specified and the final
is not an existing directory, an error will result.
<p>
In the second synopsis form, the
<i>ln</i>
utility will create a new directory entry for each file specified by a
<i>source_file</i>
operand, at a
<i>destination</i>
path in the existing directory named by
<i>target_dir</i>.
<p>
If the last operand specifies an existing file of a type not
specified by the <b>XSH</b> specification, the behaviour is implementation-dependent.
<p>
The corresponding
destination path for each
<i>source_file</i>
will be the concatenation of the
target directory pathname, a slash character, and the last pathname component
of the
<i>source_file.</i>
The second synopsis form will be assumed when
the final operand names an existing directory.
<p>
For each
<i>source_file</i>:
<ol>
<p>
<li>
If the
<i>destination</i>
path exists:
<ol type = a>
<p>
<li>
If the
<b>-f</b>
option is not specified,
<i>ln</i>
will write a diagnostic
message to standard error, do nothing more with the current
<i>source_file,</i>
and go on to any remaining
<i>source_files.</i>
<p>
<li>
Actions will be performed equivalent to the <b>XSH</b> specification
<i><a href="../xsh/unlink.html">unlink()</a></i>
function, called using
<i>destination</i>
as the
<i>path</i>
argument.
If this fails for any reason,
<i>ln</i>
will write a
diagnostic message to standard error, do nothing more with
the current
<i>source_file,</i>
and go on to any remaining
<i>source_files.</i>
<p>
</ol>
<p>
<li>
Actions will be performed equivalent to the <b>XSH</b> specification
<i><a href="../xsh/link.html">link()</a></i>
function using
<i>source_file</i>
as the
<i>path1</i>
argument, and the
<i>destination</i>
path as the
<i>path2</i>
argument.
<p>
</ol>
</blockquote><h4><a name = "tag_001_014_1159">&nbsp;</a>OPTIONS</h4><blockquote>
The
<i>ln</i>
utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b>&nbsp;</a> .
<p>
The following option is supported:
<dl compact>

<dt><b>-f</b>
<dd>Force existing
<i>destination</i>
pathnames to be removed
to allow the link.

</dl>
</blockquote><h4><a name = "tag_001_014_1160">&nbsp;</a>OPERANDS</h4><blockquote>
The following operands are supported:
<dl compact>

<dt><i>source_file</i><dd>
A pathname of a file to be linked.
This can be a regular or special file;
whether a directory can be linked is implementation-dependent.

<dt><i>target_file</i><dd>
The pathname of the new directory entry to be created.

<dt><i>target_dir</i><dd>
A pathname of an existing directory in which the new directory
entries are to be created.

</dl>
</blockquote><h4><a name = "tag_001_014_1161">&nbsp;</a>STDIN</h4><blockquote>
Not used.
</blockquote><h4><a name = "tag_001_014_1162">&nbsp;</a>INPUT FILES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_1163">&nbsp;</a>ENVIRONMENT VARIABLES</h4><blockquote>
The following environment variables affect the execution of
<i>ln</i>:
<dl compact>

<dt><i>LANG</i><dd>Provide a default value for the internationalisation variables
that are unset or null.
If
<i>LANG</i>
is unset or null, the corresponding value from the
implementation-dependent default locale will be used.
If any of the internationalisation variables contains an invalid setting, the
utility will behave as if none of the variables had been defined.

<dt><i>LC_ALL</i><dd>
If set to a non-empty string value,
override the values of all the other internationalisation variables.

<dt><i>LC_CTYPE</i><dd>
Determine the
locale for the interpretation of sequences of bytes of text data as
characters (for example, single- as opposed to multi-byte characters
in arguments).

<dt><i>LC_MESSAGES</i><dd>
Determine the locale that should be used to affect
the format and contents of diagnostic
messages written to standard error.

<dt><i>NLSPATH</i><dd>
Determine the location of message catalogues
for the processing of
<i>LC_MESSAGES .
</i>
</dl>
</blockquote><h4><a name = "tag_001_014_1164">&nbsp;</a>ASYNCHRONOUS EVENTS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_1165">&nbsp;</a>STDOUT</h4><blockquote>
Not used.
</blockquote><h4><a name = "tag_001_014_1166">&nbsp;</a>STDERR</h4><blockquote>
Used only for diagnostic messages.
</blockquote><h4><a name = "tag_001_014_1167">&nbsp;</a>OUTPUT FILES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_1168">&nbsp;</a>EXTENDED DESCRIPTION</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_1169">&nbsp;</a>EXIT STATUS</h4><blockquote>
The following exit values are returned:
<dl compact>

<dt>0<dd>All the specified files were linked successfully.

<dt>&gt;0<dd>An error occurred.

</dl>
</blockquote><h4><a name = "tag_001_014_1170">&nbsp;</a>CONSEQUENCES OF ERRORS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_1171">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_1172">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_1173">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_1174">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="chmod.html">chmod</a></i>,
<i><a href="find.html">find</a></i>,
<i><a href="pax.html">pax</a></i>,
<i><a href="rm.html">rm</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
